<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .box{
            width: 1200px;
            height: 500px;
            margin: 0 auto;
        }
        .box>ul{
            font-size: 0;
        }
        .box>ul>li{
            list-style: none;
            display: inline-block;
            background: #f2f2f2;
        }
        .box>ul>li>a{
            text-decoration: none;
            display:block;
            width: 100px;
            height: 40px;
            text-align: center;
            line-height: 40px;
            font-size:14px;
            color: #333;
        }
        .box>.cont>p{
            display: none;
        }
        .box>ul>li.on>a{
            background: #2798d3;
            color: #fff;
        }
        .box>.cont>p.on{
            display: block;
        }

    </style>

</head>

<body>
<div class="box">
    <ul>
        <li class="on"><a href="javascript:;" onclick="to(0);">按钮1</a></li>
        <li><a href="javascript:;" onclick="to(1);">按钮2</a></li>
        <li><a href="javascript:;" onclick="to(2);">按钮3</a></li>
    </ul>
    <div class="cont">
        <p class="on">内容1</p>
        <p>内容2</p>
        <p>内容3</p>
    </div>
</div>
<script type="text/javascript">
    function to(index){
        var a = document.querySelector('.box ul li');
        var b = document.querySelector('.box .cont p');
        a[0].className = '';
        a[1].className = '';
        a[2].className = '';
        a[index].className = 'on';
        b[0].className = '';
        b[1].className = '';
        b[2].className = '';
        b[index].className = 'on';
    }
</script>
</body>
</html>